import request from "@/utils/request";

// 获取员工简单列表
export const getEmployeeSimpleApi = () => {
  return request({
    url: "/sys/user/simple",
  });
};

//  查询员工列表
export const getEmployeesListApi = (params) => {
  return request({
    url: "/sys/user",
    method: "get",
    params,
  });
};
//  查询员工详情
export const getEmployeesInfoApi = (id) => {
  return request({
    url: "/sys/user/" + id,
    method: "get",
  });
};
// 新增员工
export const addEmployeesApi = (data) => {
  return request({
    url: "/sys/user",
    method: "post",
    data,
  });
};
// 修改员工
export const editEmployeesApi = (data) => {
  return request({
    url: "/sys/user/" + data.id,
    method: "put",
    data,
  });
};
// 删除员工
export const delEmployeesApi = (id) => {
  return request({
    url: "/sys/user/" + id,
    method: "delete",
  });
};

// 批量导入员工
// data: {字段:数据}
// data: 数据
export const batchImportUser = (data) => {
  return request({
    url: "/sys/user/batch",
    method: "post",
    data,
  });
};

/** *
 *  读取用户详情的基础信息
 * **/
export function getPersonalDetail(id) {
  return request({
    url: `/employees/${id}/personalInfo`,
  });
}

/** *
 *  更新用户详情的基础信息
 * **/
export function updatePersonal(data) {
  return request({
    url: `/employees/${data.userId}/personalInfo`,
    method: "put",
    data,
  });
}

/** **
 * 获取用户的岗位信息
 *
 * ****/
export function getJobDetail(id) {
  return request({
    url: `/employees/${id}/jobs`,
  });
}

/**
 * 保存岗位信息
 * ****/
export function updateJob(data) {
  return request({
    url: `/employees/${data.userId}/jobs`,
    method: "put",
    data,
  });
}

// 给员工分配角色
// data 类型  { id:员工ID，roleIds ：角色Id数组 }
export const setRoleAuth = (data) => {
  return request({
    url: "/sys/user/assignRoles",
    method: "put",
    data,
  });
};
